<%@ page language="java" import="java.util.*,entity.*"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'subjects.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script>
	$(function() {
		$("input[name=p]").keydown(function(e) {
			//alert(e.keyCode);//13
			if (e.keyCode == 13) {
				location = "subjectServlet?p=" + $(this).val();
			}
		}).blur(function() {
			location = "subjectServlet?p=" + $(this).val();
		});
	});
</script>
</head>

<body>
	<h1>课程列表</h1>

	<table border="1" cellpadding="0" cellspacing="0">
		<tr>
			<td>课程号</td>
			<td>课程名</td>
			<td>学时</td>
			<td>年级</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${datas}" var="s">
			<tr>
				<td>${s.id}</td>
				<td>${s.subjectname}</td>
				<td>${s.classHour}</td>
				<td>${s.gradeid}</td>
				<td>
				<a href="deleteSubjectServlet?id=${s.id}">删除</a>
				</td>
			</tr>
		</c:forEach>
	</table>
	
	<p>
		<a href="subjectServlet?p=1">首页</a>
		<c:if test="${pageNo>1}">
			<a href="subjectServlet?p=${pageNo-1}">上一页</a>
		</c:if>
		<input type="number" size="4" style="width:30px" name="p"
			value="${pageNo}" />
		<c:if test="${pageNo<totalPages}">
			<a href="subjectServlet?p=${pageNo+1}">下一页</a>
		</c:if>
		<a href="subjectServlet?p=${totalPages}">尾页</a>
	</p>
</body>
</html>
